<?php

require_once "dbconnect.php";

$driver_id = $_POST['driver_id'];
if( empty($driver_id) ) $driver_id = $_GET['driver_id'];

$only_active = $_POST['is_active'];
if( empty($only_active) ) $only_active = $_GET['is_active'];

//echo "state_name = ".$state_name."<br>";

if( !empty($driver_id) ){
	//get sub categories of the category with id = parent_id
	$sql = "SELECT * FROM driver_detail WHERE id='$driver_id'";
}
else {
	//get all categories
	echo json_encode(array("status"=>"error"));
	exit();
}
$res = $db->query($sql);

//For debug:
//echo "Total categories found: ".$res->num_rows;
//echo "<br>";

if( $res->num_rows == 0 ){
	echo json_encode(array("status"=>"error"));
	exit();
} else {
	$i=0;
	$car =  $res->rows[$i];
echo json_encode(array("status"=>"ok","driver_details"=>$car));
}

?>
